package com.plian.system.service.pm.listedcompany.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.pm.listedcompany.TenShareHolders;
import com.plian.system.mapper.pm.listedcompany.TenShareHoldersMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.pm.listedcompany.ITenShareHoldersService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@Service
@AllArgsConstructor
public class TenShareHoldersServiceImpl extends BaseServiceImpl<TenShareHoldersMapper, TenShareHolders> implements ITenShareHoldersService {

    @Override
    public boolean deleteByParentId(List<Long> ids) {
        LambdaQueryWrapper<TenShareHolders> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(TenShareHolders::getBaseFirmId, ids);
        List<TenShareHolders> tenShareHolders = list(queryWrapper);
        if (CollectionUtil.isNotEmpty(tenShareHolders)){
            return deleteLogic(tenShareHolders.stream().map(TenShareHolders::getId).collect(Collectors.toList()));
        }
        return true;
    }
}
